/*
 * AndConditionImpl.h
 *
 *  Created on: 2010-8-28
 *      Author: Xairy
 */

#ifndef CONDITIONIMPL_H_XAIRY
#define CONDITIONIMPL_H_XAIRY

#include "ChildCondition.h"
#include <string>
using std::string;

class AttributeConditionImpl : public AttributeCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	virtual const string* toString()const;

	virtual const string* getNameSpaceURI()const;
	virtual const string* getLocalName()const;
	virtual bool getSpecified()const;
	virtual const string* getValue()const;

public:
	AttributeConditionImpl();
	AttributeConditionImpl(const string& _localName,
			               const string& _value);
	virtual ~AttributeConditionImpl();

	inline void setLocalName(const string& _localName)
	{
		localName = _localName;
	}

	inline void setValue(const string& _value)
	{
		value = _value;
	}

private:
    string localName;
    string value;
};

class IdConditionImpl : public AttributeCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	const string* toString()const;

	virtual const string* getNameSpaceURI()const;
	virtual const string* getLocalName()const;
	virtual bool getSpecified()const;
	virtual const string* getValue()const;

public:
	IdConditionImpl();
	IdConditionImpl(const string& _value);
	virtual ~IdConditionImpl();

	inline void setValue(const string& _value)
	{
		value = _value;
	}

private:
	string value;
};

class ClassConditionImpl : public AttributeCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	const string* toString()const;

	virtual const string* getNameSpaceURI()const;
	virtual const string* getLocalName()const;
	virtual bool getSpecified()const;
	virtual const string* getValue()const;

public:
	ClassConditionImpl();
	ClassConditionImpl(const string& _value);
	virtual ~ClassConditionImpl();

	inline void setValue(const string& _value)
	{
		value = _value;
	}

private:
	string value;
};

class PseudoClassConditionImpl : public AttributeCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	const string* toString()const;

	virtual const string* getNameSpaceURI()const;
	virtual const string* getLocalName()const;
	virtual bool getSpecified()const;
	virtual const string* getValue()const;

public:
	PseudoClassConditionImpl();
	PseudoClassConditionImpl(const string& _value);
	virtual ~PseudoClassConditionImpl();

	inline void setValue(const string& _value)
	{
		value = _value;
	}

private:
	string value;
};

class LangConditionImpl : public LangCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	virtual const string* toString()const;

	virtual const string* getLang()const;

public:
	LangConditionImpl();
	LangConditionImpl(const string& _lang);
	virtual ~LangConditionImpl();

	inline void setLang(const string& _lang)
	{
		lang = _lang;
	}

private:
	string lang;
};

class AndConditionImpl : public CombinatorCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	virtual const string* toString()const;

	virtual const Condition& getFirstCondition()const ;
	virtual const Condition& getSecondCondition()const ;

public:
	AndConditionImpl(Condition* _first, Condition* _second);
	AndConditionImpl(const AndConditionImpl& aAndConditon);
	virtual ~AndConditionImpl();

	AndConditionImpl& operator=(const AndConditionImpl& aAndCondition);

	inline void setFirstCondition(Condition* _first)
	{
		if(firstCondition)
		{
			delete firstCondition;
			firstCondition = NULL;
		}
		firstCondition = _first->Copy();
	}

	inline void setSecondCondition(Condition* _Second)
	{
		if(secondCondition)
		{
			delete secondCondition;
			secondCondition = NULL;
		}
		secondCondition = _Second->Copy();
	}

private:
	Condition* firstCondition;
	Condition* secondCondition;
};

class BeginHyphenAttributeConditionImpl : public AttributeCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	virtual const string* toString()const;

	virtual const string* getNameSpaceURI()const;
	virtual const string* getLocalName()const;
	virtual bool getSpecified()const;
	virtual const string* getValue()const;

public:
	BeginHyphenAttributeConditionImpl();
	BeginHyphenAttributeConditionImpl(const string& _localName,
									  const string& _value);
	virtual ~BeginHyphenAttributeConditionImpl();

	inline void setLocalName(const string& _localName)
	{
		localName = _localName;
	}

	inline void setValue(const string& _value)
	{
		value = _value;
	}

private:
	string localName;
	string value;
};

class OneOfAttributeConditionImpl : public AttributeCondition
{
public:
	virtual ConditionType getConditionType()const;
	virtual Condition* Copy()const;
	virtual const string* toString()const;

	virtual const string* getNameSpaceURI()const;
	virtual const string* getLocalName()const;
	virtual bool getSpecified()const;
	virtual const string* getValue()const;

public:
	OneOfAttributeConditionImpl();
	OneOfAttributeConditionImpl(const string& _localName,
									  const string& _value);
	virtual ~OneOfAttributeConditionImpl();

	inline void setLocalName(const string& _localName)
	{
		localName = _localName;
	}

	inline void setValue(const string& _value)
	{
		value = _value;
	}

private:
	string localName;
	string value;
};

class ConditionFactoryImpl : public ConditionFactory
{
public:
	virtual CombinatorCondition* createAndCondition(Condition* First,
			                       Condition* Second)throw(CSSException) ;

	virtual CombinatorCondition* createOrCondition(Condition* First,
			                       Condition* Second)throw(CSSException) ;

	virtual NegativeCondition* createNegativeCondition(Condition* condition)
			                     throw(CSSException) ;

	virtual PositionalCondition* createPositionalCondition(int position,
								 bool typeNode,
			                     bool type)throw(CSSException) ;

	virtual AttributeCondition* createAttributeCondition(const string& localName,
								 const string* namespaceURI,
								 bool specified,
			                     const string& value)throw(CSSException) ;

	virtual LangCondition* createLangCondition(const string& lang)
	                         throw(CSSException) ;

	virtual AttributeCondition* createOneOfAttributeCondition(
			                      const string& localName,
								  const string* namespaceURI,
								  bool specified,
								  const string& value)throw(CSSException) ;

	virtual AttributeCondition* createBeginHyphenAttributeCondition(
								  const string& localName,
								  const string* namespaceURI,
			                      bool specified,
			                      const string& value)throw(CSSException) ;

	virtual AttributeCondition* createClassCondition(
			                      const string* namespaceURI,
								  const string& value)throw(CSSException) ;

	virtual AttributeCondition* createPseudoClassCondition(
			                      const string* namespaceURI,
							      const string& value)throw(CSSException) ;
	virtual AttributeCondition* createIdCondition(
								  const string& value)throw(CSSException) ;

	virtual Condition* createOnlyChildCondition()throw(CSSException) ;

	virtual Condition* createOnlyTypeCondition()throw(CSSException) ;

	virtual ContentCondition* createContentCondition(const string& data)
								throw(CSSException) ;

};

#endif /* ANDCONDITIONIMPL_H_ */
